package com.lianxian.xindong.life.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.util.Xml;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.lianxian.xindong.life.R;
import com.lianxian.xindong.life.R2;
import com.lianxian.xindong.life.adapter.MeiShiRecyclerViewAdapter;
import com.lianxian.xindong.life.entities.MeiShiRecyclerModel;
import com.lianxian.xindong.life.entities.MenuPicAndName;
import com.lianxian.xindong.life.entities.bean.FilterAreaOneEntity;
import com.lianxian.xindong.life.entities.bean.FilterAreaThreeEntity;
import com.lianxian.xindong.life.entities.bean.FilterAreaTwoEntity;
import com.lianxian.xindong.life.entities.bean.FilterMulSelectEntity;
import com.lianxian.xindong.life.entities.bean.FilterSelectedEntity;
import com.yangbin.FilterTabConfig;
import com.yangbin.base.BaseFilterBean;
import com.yangbin.bean.FilterInfoBean;
import com.yangbin.bean.FilterResultBean;
import com.yangbin.listener.OnSelectResultListener;
import com.yangbin.view.FilterTabView;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.mtjsoft.www.gridviewpager_recycleview.GridViewPager;

public class FoodActivity extends AppCompatActivity implements OnSelectResultListener {
    private FilterTabView mFtbFilter;
    private List<BaseFilterBean> mAreaList = new ArrayList<>();//区域
    private List<BaseFilterBean> mAllPriceList = new ArrayList<>();//总价
    private List<BaseFilterBean> mSortList = new ArrayList<>();//排序
    private List<BaseFilterBean> mAreaSizeList = new ArrayList<>();//平数
    private List<BaseFilterBean> mMoreList = new ArrayList<>();//更多
    private List<BaseFilterBean> mSinglePriceList = new ArrayList<>();//单价

    GridViewPager gridViewPager;
    @BindView(R2.id.meishi_recyclerview)
    RecyclerView recyclerView;
    List<MenuPicAndName> list;
    @BindView(R2.id.search_business_icon)
    ImageView searchIcon;
    List<MeiShiRecyclerModel> meiShiRecyclerModelList;
    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_food);
        ButterKnife.bind(this);
        gridViewPager = findViewById(R.id.meishi_grid_pager);
//        recyclerView = findViewById(R.id.meishi_recyclerview);
        initData();
        gridViewPager
                // 设置数据总数量
                .setDataAllCount(list.size())
                // 设置背景色，默认白色
//                .setGridViewPagerBackgroundColor(ContextCompat.getColor(getActivity(), R.color.white))
                // 设置item的纵向间距
                .setVerticalSpacing(10)
                // 设置上边距
                .setPagerMarginTop(20)
                // 设置下边距
                .setPagerMarginBottom(10)
                // 设置图片宽度
                .setImageWidth(42)
                // 设置图片高度
                .setImageHeight(42)
                // 设置文字与图片的间距
                .setTextImgMargin(5)
                // 设置文字颜色
                .setTextColor(ContextCompat.getColor(this, R.color.white))
                // 设置文字大小
                .setTextSize(12)
                .setTextColor(Color.BLACK)
                // 设置每页行数
                .setRowCount(2)
                // 设置每页列数
                .setColumnCount(5)
                // 设置是否显示指示器
                .setPointIsShow(true)
                // 设置指示器与page的间距
                .setPointMarginPage(10)
                // 设置指示器与底部的间距
                .setPointMarginBottom(10)
                // 设置指示器的item宽度
                .setPointChildWidth(8)
                // 设置指示器的item高度
                .setPointChildHeight(8)
                // 设置指示器的item的间距
                .setPointChildMargin(8)
                // 指示器的item是否为圆形，默认圆形直径取宽高的最小值
                .setPointIsCircle(true)
                // 指示器item未选中的颜色
                .setPointNormalColor(ContextCompat.getColor(this, R.color.white))
                // 指示器item选中的颜色
                .setPointSelectColor(ContextCompat.getColor(this, R.color.black))
                // 设置背景图片(此时设置的背景色无效，以背景图片为主)
//                .setBackgroundImageLoader(new GridViewPager.BackgroundImageLoaderInterface() {
//                    @Override
//                    public void setBackgroundImg(ImageView bgImageView) {
//
//                    }
//                })
                // 数据绑定
                .setImageTextLoaderInterface(new GridViewPager.ImageTextLoaderInterface() {
                    @Override
                    public void displayImageText(ImageView imageView, TextView textView, int position) {
                        // 自己进行数据的绑定，灵活度更高，不受任何限制
                        imageView.setImageResource(list.get(position).getPicResourceId());
                        textView.setText(list.get(position).getName());
                    }
                })
                // Item点击
                .setGridItemClickListener(new GridViewPager.GridItemClickListener() {
                    @Override
                    public void click(int position) {
                        MenuPicAndName data =list.get(position);
                        if ("美食排行".equals(data.getName())){
                            Intent intent = new Intent(FoodActivity.this,FoodRankingActivity.class);
                            startActivity(intent);
                        }
                        Toast.makeText(FoodActivity.this, "点击了" + list.get(position).getName() + position, Toast.LENGTH_SHORT).show();

                    }
                })
                .show();

        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setAdapter(new MeiShiRecyclerViewAdapter(this, meiShiRecyclerModelList));

        initView();
        setFilterViewAndData();
        mFtbFilter.setOnSelectResultListener(this);

    }
    private void initView() {
        mFtbFilter = findViewById(R.id.ftb_filter);
        mFtbFilter.setColorMain(getResources().getColor(R.color.color_FF6F00));
        mFtbFilter.removeViews();
        searchIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(FoodActivity.this,BusinessDetailActivity.class);
                startActivity(intent);
            }
        });
    }
    @Override
    public void onSelectResult(FilterResultBean resultBean, int postion) {
        String message = "";
        if (resultBean.getPopupType() == 3) {
            List<FilterResultBean.MulTypeBean> list = resultBean.getSelectList();
            for (int i = 0; i < list.size(); i++) {
                FilterResultBean.MulTypeBean bean = list.get(i);
                if (i == (list.size() - 1)) {
                    message = message + bean.getItemName();
                } else {
                    message = message + bean.getItemName() + ",";
                }
            }
        } else {
            message = resultBean.getItemId() + ":" + resultBean.getName();
        }

        Toast.makeText(this, message, Toast.LENGTH_LONG).show();

    }
    @Override
    public void onSelectResultList(List<FilterResultBean> resultBeans, int postion) {
        String message = "";
        List<FilterResultBean> list = resultBeans;
        for (int i = 0; i < list.size(); i++) {
            FilterResultBean bean = list.get(i);
            if (i == (list.size() - 1)) {
                message = message + bean.getName();
            } else {
                message = message + bean.getName() + ",";
            }
        }
        Toast.makeText(this, message, Toast.LENGTH_LONG).show();

        Log.e("选中的", "name:" + list.get(0).getName() + "/1-Id:" + list.get(0).getItemId() + "/2-Id:" + list.get(0).getChildId());
        mFtbFilter.resetTab(postion, mSinglePriceList, "附近");
    }

    private void setFilterViewAndData() {
        FilterInfoBean bean_area = new FilterInfoBean("附近", FilterTabConfig.FILTER_TYPE_THREE_MENU, mAreaList);
        FilterInfoBean bean_price = new FilterInfoBean("美食", FilterTabConfig.FILTER_TYPE_PRICE_UPRIGHT, mAllPriceList);
        FilterInfoBean bean_sort = new FilterInfoBean("智能排序", FilterTabConfig.FILTER_TYPE_PRICE_UPRIGHT, mSortList);
        FilterInfoBean bean_more = new FilterInfoBean("筛选", FilterTabConfig.FILTER_TYPE_MUL_SELECT, mMoreList);
        FilterInfoBean bean5 = new FilterInfoBean("坪数", FilterTabConfig.FILTER_TYPE_SINGLE_GIRD, mAreaSizeList);
        FilterInfoBean bean6 = new FilterInfoBean("单价", FilterTabConfig.FILTER_TYPE_PRICE_HORIZONTAL, mSinglePriceList);

        mFtbFilter.addFilterItem(bean_area.getTabName(), bean_area.getFilterData(), bean_area.getPopupType(), 0, false);
//        mFtbFilter.addFilterItem(bean_price.getTabName(), bean_price.getFilterData(), bean_price.getPopupType(), 1, false);
//        mFtbFilter.addFilterItem(bean_sort.getTabName(), bean_sort.getFilterData(), bean_sort.getPopupType(), 2, false);
//        mFtbFilter.addFilterItem(bean_more.getTabName(), bean_more.getFilterData(), bean_more.getPopupType(), 3, false);
//        mFtbFilter.addFilterItem(bean5.getTabName(), bean5.getFilterData(), bean5.getPopupType(), 4, false);
//        mFtbFilter.addFilterItem(bean6.getTabName(), bean6.getFilterData(), bean6.getPopupType(), 5, false);
    }

    private void initData() {
        list = new ArrayList<>();
        MenuPicAndName menuPicAndName = new MenuPicAndName(R.mipmap.life_group_142, "美食排行");
        list.add(menuPicAndName);
        menuPicAndName = new MenuPicAndName(R.mipmap.life_group_143, "下午茶");
        list.add(menuPicAndName);
        menuPicAndName = new MenuPicAndName(R.mipmap.life_group_151, "商场美食");
        list.add(menuPicAndName);
        menuPicAndName = new MenuPicAndName(R.mipmap.life_group_149, "网红美食");
        list.add(menuPicAndName);
        menuPicAndName = new MenuPicAndName(R.mipmap.life_group_153, "小吃快餐");
        list.add(menuPicAndName);
        menuPicAndName = new MenuPicAndName(R.mipmap.life_group_154, "饮品");
        list.add(menuPicAndName);
        menuPicAndName = new MenuPicAndName(R.mipmap.life_group_150, "新店");
        list.add(menuPicAndName);
        meiShiRecyclerModelList = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            MeiShiRecyclerModel meiShiRecyclerModel = new MeiShiRecyclerModel("https://img1.baidu.com/it/u=161395353,585157698&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500", 3, 6, "去山里楼顶天空bar",
                    "融合烤肉 观音桥", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2Ffc2d272d-3899-4af7-a6b0-bcb640b9cdd2%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1691137008&t=88eb3ef61c23c55bd9d5ca3410f4ed38"
                    , "不错的一次体验", 156, 4.5f, "儿童套餐（限1米4以下儿童使用）", 100);
            meiShiRecyclerModelList.add(meiShiRecyclerModel);
            meiShiRecyclerModel = null;
        }

        setAreaData();
        setAllPriceData();
        setSinglePriceData();
        setSortData();
        setMoreData();
    }

    private void setAreaData2() {
        try {
            FilterAreaOneEntity filterOneEntity_a = new FilterAreaOneEntity();
            filterOneEntity_a.setArea_id(0);
            filterOneEntity_a.setName("区域0");
            filterOneEntity_a.setSelected(1);
            filterOneEntity_a.setFilterAreaEntityList(loadAreaData());

            FilterAreaOneEntity filterOneEntity_b = new FilterAreaOneEntity();
            filterOneEntity_b.setArea_id(1);
            filterOneEntity_b.setName("捷运1");
            filterOneEntity_b.setSelected(0);
            filterOneEntity_b.setFilterAreaEntityList(loadSubWayData());

            FilterAreaOneEntity filterOneEntity_c = new FilterAreaOneEntity();
            filterOneEntity_c.setArea_id(2);
            filterOneEntity_c.setName("附近2");
            filterOneEntity_c.setSelected(0);
            filterOneEntity_c.setFilterAreaEntityList(loadNearData());


            mAreaList.add(filterOneEntity_a);
            mAreaList.add(filterOneEntity_b);
            mAreaList.add(filterOneEntity_c);
        } catch (Exception e) {

        }
    }
    private void setAreaData() {
        String areaString = "[{\n" +
                "\t\"id\": 1,\n" +
                "\t\"name\": \"行政区/商区\",\n" +
                "\t\"second_datas\": [{\n" +
                "\t\t\"id\": 1,\n" +
                "\t\t\"name\": \"热门商区\",\n" +
                "\t\t\"third_datas\": [{\n" +
                "\t\t\t\"id\": 1,\n" +
                "\t\t\t\"name\": \"大坪\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 2,\n" +
                "\t\t\t\"name\": \"三峡广场\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 3,\n" +
                "\t\t\t\"name\": \"解放碑\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 4,\n" +
                "\t\t\t\"name\": \"观音桥\"\n" +
                "\t\t}]\n" +
                "\t}, {\n" +
                "\t\t\"id\": 2,\n" +
                "\t\t\"name\": \"全城\",\n" +
                "\t\t\"third_datas\": [{\n" +
                "\t\t\t\"id\": 1,\n" +
                "\t\t\t\"name\": \"大坪\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 2,\n" +
                "\t\t\t\"name\": \"三峡广场\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 3,\n" +
                "\t\t\t\"name\": \"解放碑\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 4,\n" +
                "\t\t\t\"name\": \"观音桥\"\n" +
                "\t\t}]\n" +
                "\t}, {\n" +
                "\t\t\"id\": 2,\n" +
                "\t\t\"name\": \"渝中\",\n" +
                "\t\t\"third_datas\": [{\n" +
                "\t\t\t\"id\": 1,\n" +
                "\t\t\t\"name\": \"大坪\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 2,\n" +
                "\t\t\t\"name\": \"三峡广场\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 3,\n" +
                "\t\t\t\"name\": \"解放碑\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 4,\n" +
                "\t\t\t\"name\": \"观音桥\"\n" +
                "\t\t}]\n" +
                "\t}]\n" +
                "}, {\n" +
                "\t\"id\": 2,\n" +
                "\t\"name\": \"地铁\",\n" +
                "\t\"second_datas\": [{\n" +
                "\t\t\"id\": 1,\n" +
                "\t\t\"name\": \"地铁一号线\",\n" +
                "\t\t\"third_datas\": [{\n" +
                "\t\t\t\"id\": 1,\n" +
                "\t\t\t\"name\": \"大坪\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 2,\n" +
                "\t\t\t\"name\": \"三峡广场\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 3,\n" +
                "\t\t\t\"name\": \"解放碑\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 4,\n" +
                "\t\t\t\"name\": \"观音桥\"\n" +
                "\t\t}]\n" +
                "\t}, {\n" +
                "\t\t\"id\": 2,\n" +
                "\t\t\"name\": \"地铁二号线\",\n" +
                "\t\t\"third_datas\": [{\n" +
                "\t\t\t\"id\": 1,\n" +
                "\t\t\t\"name\": \"大坪\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 2,\n" +
                "\t\t\t\"name\": \"三峡广场\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 3,\n" +
                "\t\t\t\"name\": \"解放碑\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 4,\n" +
                "\t\t\t\"name\": \"观音桥\"\n" +
                "\t\t}]\n" +
                "\t}, {\n" +
                "\t\t\"id\": 2,\n" +
                "\t\t\"name\": \"地铁三号线\",\n" +
                "\t\t\"third_datas\": [{\n" +
                "\t\t\t\"id\": 1,\n" +
                "\t\t\t\"name\": \"大坪\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 2,\n" +
                "\t\t\t\"name\": \"三峡广场\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 3,\n" +
                "\t\t\t\"name\": \"解放碑\"\n" +
                "\t\t}, {\n" +
                "\t\t\t\"id\": 4,\n" +
                "\t\t\t\"name\": \"观音桥\"\n" +
                "\t\t}]\n" +
                "\t}]\n" +
                "}]";
        JSONArray jsonArray = JSONArray.parse(areaString);
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            FilterAreaOneEntity filterOneEntity = new FilterAreaOneEntity();
            filterOneEntity.setName(jsonObject.getString("name"));
            if (i==0){
                filterOneEntity.setSelected(1);
            }
//            filterOneEntity.setArea_id(i);
            FilterAreaTwoEntity twoFirst = new FilterAreaTwoEntity();
            twoFirst.setArea_id(-1);
            twoFirst.setName("不限");
//            twoFirst.setSelected(1);
            List<FilterAreaTwoEntity> areaTwoEntities = new ArrayList<>();
            areaTwoEntities.add(twoFirst);
            JSONArray jsonArraySecond = jsonObject.getJSONArray("second_datas");

            for (int j = 0; j < jsonArraySecond.size(); j++) {
                FilterAreaTwoEntity filterAreaTwoEntity = new FilterAreaTwoEntity();
                JSONObject jsonObjectSecond = jsonArraySecond.getJSONObject(j);
                String nameSecond = (String) jsonObjectSecond.get("name");
                Integer idSecond = (Integer) jsonObjectSecond.get("id");
                filterAreaTwoEntity.setName(nameSecond);
//                filterAreaTwoEntity.setArea_id(j);
                JSONArray jsonArrayThird = jsonObjectSecond.getJSONArray("third_datas");
                List<FilterAreaThreeEntity> threeEntities = new ArrayList<>();
                FilterAreaThreeEntity district = new FilterAreaThreeEntity();
//                district.setStreet_id(0);
                district.setName("不限");
                district.setSelected(0);
                threeEntities.add(district);
                for (int k = 0; k < jsonArrayThird.size(); k++) {
                    FilterAreaThreeEntity filterAreaThreeEntity = new FilterAreaThreeEntity();
                    JSONObject jsonObjectThird = jsonArrayThird.getJSONObject(k);
                    String nameThird = (String) jsonObjectThird.get("name");
                    Integer idThird = (Integer) jsonObjectThird.get("id");
                    filterAreaThreeEntity.setName(nameThird);
//                    filterAreaThreeEntity.setStreet_id(k);
                    threeEntities.add(filterAreaThreeEntity);
                }
                filterAreaTwoEntity.setChildAreas(threeEntities);
                areaTwoEntities.add(filterAreaTwoEntity);
            }
            filterOneEntity.setFilterAreaEntityList(areaTwoEntities);
            mAreaList.add(filterOneEntity);
        }

    }

    public List<FilterAreaTwoEntity> loadAreaData() {
        List<FilterAreaTwoEntity> areaList = new ArrayList<>();
        FilterAreaTwoEntity area = null;
        FilterAreaThreeEntity district;
        List<FilterAreaThreeEntity> districtList = null;
        area = new FilterAreaTwoEntity();
        area.setArea_id(0);
        area.setName("不限");
        area.setSelected(1);
        areaList.add(area);


        try {
            InputStream inputStream = FoodActivity.this.getResources().openRawResource(R.raw.location);
            XmlPullParser parser = Xml.newPullParser();
            parser.setInput(inputStream, "utf-8");
            int eventType = parser.getEventType();
            while (eventType != XmlPullParser.END_DOCUMENT) {
                switch (eventType) {
                    case XmlPullParser.START_DOCUMENT:
                        break;
                    case XmlPullParser.START_TAG:
                        String tagName = parser.getName();
                        if ("region".equals(tagName)) {
                            area = new FilterAreaTwoEntity();


                            String id = parser.getAttributeValue(null, "id");
                            String name = parser.getAttributeValue(null, "name");
                            String latitude = parser.getAttributeValue(null, "lat");
                            String longitude = parser.getAttributeValue(null, "lng");
                            int initID = Integer.parseInt(id);
                            area.setArea_id(initID);
                            area.setName(name);
                            districtList = new ArrayList<>();
                            area.setChildAreas(districtList);

                            district = new FilterAreaThreeEntity();
                            district.setStreet_id(0);
                            district.setName("不限");
                            district.setSelected(0);
                            districtList.add(district);

                        } else if ("section".equals(tagName)) {
                            String id = parser.getAttributeValue(null, "id");
                            String name = parser.nextText();
                            String latitude = parser.getAttributeValue(null, "lat");
                            String longitude = parser.getAttributeValue(null, "lng");
                            district = new FilterAreaThreeEntity();
                            int initID = Integer.parseInt(id);
                            district.setStreet_id(initID);
                            district.setName(name);
                            district.setSelected(0);
                            if (null != districtList && null != district) {
                                districtList.add(district);
                            }
                        }
                        break;
                    case XmlPullParser.END_TAG:
                        if ("region".equals(parser.getName())) {
                            if (null != areaList && null != area) {
                                areaList.add(area);
                            }
                        }
                        break;
                }
                eventType = parser.next();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return areaList;

    }

    public List<FilterAreaTwoEntity> loadSubWayData() throws IOException, XmlPullParserException {
        List<FilterAreaTwoEntity> praser1 = realPraserLine2(FoodActivity.this, R.raw.subway_taipei);
        List<FilterAreaTwoEntity> praser2 = realPraserLine2(FoodActivity.this, R.raw.subway_gaoxiong);
        List<FilterAreaTwoEntity> praser3 = realPraserLine2(FoodActivity.this, R.raw.subway_taoyuan);
        List<FilterAreaTwoEntity> praser4 = realPraserLine2(FoodActivity.this, R.raw.subway_xinbei);
        praser1.addAll(praser2);
        praser1.addAll(praser3);
        praser1.addAll(praser4);

        return praser1;

    }

    public List<FilterAreaTwoEntity> realPraserLine2(Context context, int resourceId) throws XmlPullParserException, IOException {
        List<FilterAreaTwoEntity> areaList = new ArrayList<>();

        FilterAreaTwoEntity area = null;
        FilterAreaThreeEntity district;
        List<FilterAreaThreeEntity> districtList = null;
        InputStream inStream = context.getResources().openRawResource(resourceId);
        XmlPullParser pullParser = Xml.newPullParser();
        pullParser.setInput(inStream, "UTF-8");
        int event = pullParser.getEventType();// 觸發第一個事件
        while (event != XmlPullParser.END_DOCUMENT) {
            switch (event) {
                case XmlPullParser.START_DOCUMENT:
                    break;
                case XmlPullParser.START_TAG:
                    if ("line".equals(pullParser.getName())) {
                        area = new FilterAreaTwoEntity();
                        String name = pullParser.getAttributeValue(null, "name");
                        String id = pullParser.getAttributeValue(null, "id");
                        String latitude = pullParser.getAttributeValue(null, "lat");
                        String longitude = pullParser.getAttributeValue(null, "lng");
                        String order = pullParser.getAttributeValue(null, "zoom");
                        int initID = Integer.parseInt(id);
                        area.setArea_id(initID);
                        area.setName(name);
                        districtList = new ArrayList<>();
                        area.setChildAreas(districtList);
                        district = new FilterAreaThreeEntity();
                        district.setStreet_id(0);
                        district.setName("不限");
                        district.setSelected(0);
                        districtList.add(district);
                    }
                    if ("station".equals(pullParser.getName())) {
                        String name = pullParser.getAttributeValue(null, "name");

                        String id = pullParser.getAttributeValue(null, "id");
                        String latitude = pullParser.getAttributeValue(null, "lat");
                        String longitude = pullParser.getAttributeValue(null, "lng");
                        String zoom = pullParser.getAttributeValue(null, "zoom");
                        district = new FilterAreaThreeEntity();
                        int initID = Integer.parseInt(id);
                        district.setStreet_id(initID);
                        district.setName(name);
                        if (null != districtList && null != district) {
                            districtList.add(district);
                        }
                    }
                    break;
                case XmlPullParser.END_TAG:
                    if ("line".equals(pullParser.getName())) {
                        if (null != areaList && null != area) {
                            areaList.add(area);
                        }
                    }

                    break;
                default:
                    break;
            }
            event = pullParser.next();
        }
        return areaList;
    }

    public List<FilterAreaTwoEntity> loadNearData() {
        List<FilterAreaTwoEntity> areaList = new ArrayList<>();
        FilterAreaTwoEntity area_a = new FilterAreaTwoEntity();
        area_a.setArea_id(0);
        area_a.setName("1000");
        area_a.setSelected(0);

        FilterAreaTwoEntity area_b = new FilterAreaTwoEntity();
        area_b.setArea_id(1);
        area_b.setName("2000");
        area_b.setSelected(0);

        FilterAreaTwoEntity area_c = new FilterAreaTwoEntity();
        area_c.setArea_id(2);
        area_c.setName("3000");
        area_c.setSelected(0);

        areaList.add(area_a);
        areaList.add(area_b);
        areaList.add(area_c);
        return areaList;
    }
    private void setAllPriceData() {
        FilterSelectedEntity filterSelectedEntity_a = new FilterSelectedEntity();
        filterSelectedEntity_a.setTid(0);
        filterSelectedEntity_a.setName("不限");
        filterSelectedEntity_a.setSelecteStatus(1);

        FilterSelectedEntity filterSelectedEntity_b = new FilterSelectedEntity();
        filterSelectedEntity_b.setTid(1);
        filterSelectedEntity_b.setName("100");
        filterSelectedEntity_b.setSelecteStatus(0);

        FilterSelectedEntity filterSelectedEntity_c = new FilterSelectedEntity();
        filterSelectedEntity_c.setTid(2);
        filterSelectedEntity_c.setName("200");
        filterSelectedEntity_c.setSelecteStatus(0);

        FilterSelectedEntity filterSelectedEntity_d = new FilterSelectedEntity();
        filterSelectedEntity_d.setTid(3);
        filterSelectedEntity_d.setName("300");
        filterSelectedEntity_d.setSelecteStatus(0);

        FilterSelectedEntity filterSelectedEntity_e = new FilterSelectedEntity();
        filterSelectedEntity_e.setTid(4);
        filterSelectedEntity_e.setName("400");
        filterSelectedEntity_e.setSelecteStatus(0);

        FilterSelectedEntity filterSelectedEntity_f = new FilterSelectedEntity();
        filterSelectedEntity_f.setTid(5);
        filterSelectedEntity_f.setName("500");
        filterSelectedEntity_f.setSelecteStatus(0);

        FilterSelectedEntity filterSelectedEntity_g = new FilterSelectedEntity();
        filterSelectedEntity_g.setTid(6);
        filterSelectedEntity_g.setName("600");
        filterSelectedEntity_g.setSelecteStatus(0);

        mAllPriceList.add(filterSelectedEntity_a);
        mAllPriceList.add(filterSelectedEntity_b);
        mAllPriceList.add(filterSelectedEntity_c);
        mAllPriceList.add(filterSelectedEntity_d);
        mAllPriceList.add(filterSelectedEntity_e);
        mAllPriceList.add(filterSelectedEntity_f);
        mAllPriceList.add(filterSelectedEntity_g);
    }

    private void setSinglePriceData() {
        FilterSelectedEntity filterSelectedEntity_a = new FilterSelectedEntity();
        filterSelectedEntity_a.setTid(0);
        filterSelectedEntity_a.setName("不限");
        filterSelectedEntity_a.setSelecteStatus(1);


        FilterSelectedEntity filterSelectedEntity_b = new FilterSelectedEntity();
        filterSelectedEntity_b.setTid(1);
        filterSelectedEntity_b.setName("1000");
        filterSelectedEntity_b.setSelecteStatus(0);

        FilterSelectedEntity filterSelectedEntity_c = new FilterSelectedEntity();
        filterSelectedEntity_c.setTid(2);
        filterSelectedEntity_c.setName("2000");
        filterSelectedEntity_c.setSelecteStatus(0);

        FilterSelectedEntity filterSelectedEntity_d = new FilterSelectedEntity();
        filterSelectedEntity_d.setTid(3);
        filterSelectedEntity_d.setName("3000");
        filterSelectedEntity_d.setSelecteStatus(0);

        FilterSelectedEntity filterSelectedEntity_e = new FilterSelectedEntity();
        filterSelectedEntity_e.setTid(4);
        filterSelectedEntity_e.setName("4000");
        filterSelectedEntity_e.setSelecteStatus(0);

        FilterSelectedEntity filterSelectedEntity_f = new FilterSelectedEntity();
        filterSelectedEntity_f.setTid(5);
        filterSelectedEntity_f.setName("5000");
        filterSelectedEntity_f.setSelecteStatus(0);

        FilterSelectedEntity filterSelectedEntity_g = new FilterSelectedEntity();
        filterSelectedEntity_g.setTid(6);
        filterSelectedEntity_g.setName("6000");
        filterSelectedEntity_g.setSelecteStatus(0);

        mSinglePriceList.add(filterSelectedEntity_a);
        mSinglePriceList.add(filterSelectedEntity_b);
        mSinglePriceList.add(filterSelectedEntity_c);
        mSinglePriceList.add(filterSelectedEntity_d);
        mSinglePriceList.add(filterSelectedEntity_e);
        mSinglePriceList.add(filterSelectedEntity_f);
        mSinglePriceList.add(filterSelectedEntity_g);
    }

    private void setSortData() {


        FilterSelectedEntity sortBean_a = new FilterSelectedEntity();
        sortBean_a.setTid(0);
        sortBean_a.setName("智能排序（根据距离人气评价等个性化推荐）");
        sortBean_a.setSelected(1);

        FilterSelectedEntity sortBean_b = new FilterSelectedEntity();
        sortBean_b.setTid(1);
        sortBean_b.setName("距离优先");
        sortBean_b.setSelected(0);

        FilterSelectedEntity sortBean_c = new FilterSelectedEntity();
        sortBean_c.setTid(2);
        sortBean_c.setName("人气优先（根据浏览数评价数等综合排序）");
        sortBean_c.setSelected(0);

        FilterSelectedEntity sortBean_d = new FilterSelectedEntity();
        sortBean_d.setTid(3);
        sortBean_d.setName("好评优先");
        sortBean_d.setSelected(0);


        FilterSelectedEntity sortBean_e = new FilterSelectedEntity();
        sortBean_e.setTid(4);
        sortBean_e.setName("口味优先");
        sortBean_e.setSelected(0);

        FilterSelectedEntity sortBean_f = new FilterSelectedEntity();
        sortBean_f.setTid(5);
        sortBean_f.setName("环境优先");
        sortBean_f.setSelected(0);


        FilterSelectedEntity sortBean_g = new FilterSelectedEntity();
        sortBean_g.setTid(6);
        sortBean_g.setName("服务优先");
        sortBean_g.setSelected(0);

        FilterSelectedEntity sortBean_1 = new FilterSelectedEntity();
        sortBean_1.setTid(7);
        sortBean_1.setName("低价优先");
        sortBean_1.setSelected(0);

        FilterSelectedEntity sortBean_2 = new FilterSelectedEntity();
        sortBean_2.setTid(8);
        sortBean_2.setName("高价优先");
        sortBean_2.setSelected(0);

        mSortList.add(sortBean_a);
        mSortList.add(sortBean_b);
        mSortList.add(sortBean_c);
        mSortList.add(sortBean_d);
        mSortList.add(sortBean_e);
        mSortList.add(sortBean_f);
        mSortList.add(sortBean_g);
        mSortList.add(sortBean_1);
        mSortList.add(sortBean_2);

        mAreaSizeList.add(sortBean_a);
        mAreaSizeList.add(sortBean_b);
        mAreaSizeList.add(sortBean_c);
        mAreaSizeList.add(sortBean_d);
        mAreaSizeList.add(sortBean_e);
        mAreaSizeList.add(sortBean_f);
        mAreaSizeList.add(sortBean_g);
        mAreaSizeList.add(sortBean_1);
        mAreaSizeList.add(sortBean_2);

    }

    private void setMoreData() {
        //形态数据集合------------------------------------
        List<FilterSelectedEntity> typeList = new ArrayList<>();
        FilterMulSelectEntity filterOneEntity = new FilterMulSelectEntity();
        filterOneEntity.setIsCan(1);
        filterOneEntity.setSelecteStatus(1);
        filterOneEntity.setSortdata(typeList);
        filterOneEntity.setSortname("形态");

        FilterSelectedEntity f_a = new FilterSelectedEntity();
        f_a.setSelected(0);
        f_a.setName("公寓");
        f_a.setSelecteStatus(0);
        f_a.setTid(1);
        typeList.add(f_a);

        FilterSelectedEntity f_b = new FilterSelectedEntity();
        f_b.setSelected(0);
        f_b.setName("电梯大楼");
        f_b.setSelecteStatus(0);
        f_b.setTid(2);
        typeList.add(f_b);

        FilterSelectedEntity f_c = new FilterSelectedEntity();
        f_c.setSelected(0);
        f_c.setName("透天");
        f_c.setSelecteStatus(0);
        f_c.setTid(3);
        typeList.add(f_c);

        FilterSelectedEntity f_d = new FilterSelectedEntity();
        f_d.setSelected(0);
        f_d.setName("别墅");
        f_d.setSelecteStatus(0);
        f_d.setTid(4);
        typeList.add(f_d);


        //屋龄数据集合------------------------------------
        FilterMulSelectEntity filterOneEntity_a = new FilterMulSelectEntity();
        List<FilterSelectedEntity> houseAgeList = new ArrayList<>();
        filterOneEntity_a.setIsCan(1);
        filterOneEntity_a.setSelecteStatus(1);
        filterOneEntity_a.setSortdata(houseAgeList);
        filterOneEntity_a.setSortname("屋龄");

        FilterSelectedEntity ff_a = new FilterSelectedEntity();
        ff_a.setSelected(0);
        ff_a.setName("5年以下");
        ff_a.setSelecteStatus(0);
        ff_a.setTid(1);
        houseAgeList.add(ff_a);

        FilterSelectedEntity ff_b = new FilterSelectedEntity();
        ff_b.setSelected(0);
        ff_b.setName("5-10年");
        ff_b.setSelecteStatus(0);
        ff_b.setTid(2);
        houseAgeList.add(ff_b);

        FilterSelectedEntity ff_c = new FilterSelectedEntity();
        ff_c.setSelected(0);
        ff_c.setName("10-20年");
        ff_c.setSelecteStatus(0);
        ff_c.setTid(3);
        houseAgeList.add(ff_c);

        FilterSelectedEntity ff_d = new FilterSelectedEntity();
        ff_d.setSelected(0);
        ff_d.setName("20-30年");
        ff_d.setSelecteStatus(0);
        ff_d.setTid(4);
        houseAgeList.add(ff_d);


//---------------------------------------------


        FilterMulSelectEntity filterOneEntity_b = new FilterMulSelectEntity();
        List<FilterSelectedEntity> floorList = new ArrayList<>();
        filterOneEntity_b.setIsCan(1);
        filterOneEntity_b.setSelecteStatus(1);
        filterOneEntity_b.setSortdata(floorList);
        filterOneEntity_b.setSortname("楼层");
        FilterSelectedEntity fff_a = new FilterSelectedEntity();
        fff_a.setSelected(0);
        fff_a.setName("1楼以下");
        fff_a.setSelecteStatus(0);
        fff_a.setTid(1);
        floorList.add(fff_a);

        FilterSelectedEntity fff_c = new FilterSelectedEntity();
        fff_c.setSelected(0);
        fff_c.setName("1-3楼");
        fff_c.setSelecteStatus(0);
        fff_c.setTid(2);
        floorList.add(fff_c);

        FilterSelectedEntity fff_d = new FilterSelectedEntity();
        fff_d.setSelected(0);
        fff_d.setName("4-6楼");
        fff_d.setSelecteStatus(0);
        fff_d.setTid(3);
        floorList.add(fff_d);

        FilterSelectedEntity fff_e = new FilterSelectedEntity();
        fff_e.setSelected(0);
        fff_e.setName("7-9楼");
        fff_e.setSelecteStatus(0);
        fff_e.setTid(4);
        floorList.add(fff_e);


        mMoreList.add(filterOneEntity);
        mMoreList.add(filterOneEntity_a);
        mMoreList.add(filterOneEntity_b);
    }

}